[E2010][EWS-XML][JAVA]How to get the properties of meeting rooms in Exchange 2010 using EWS Java API

When you look at meeting room properties in Outlook 2010, you can see 'City', 'Country/Region' and 'Department' information.

Is there any way to get this information using EWS Java API? 


August 2nd, 2012 2:30pm

You need to use the ResolveName operation and specify to return the Contact information from Active Directory in the Java EWS api you should be able to use the resolveName Method from the ExchangeService class eg something like

NameResolutionCollection nameResolutions = service.resolveName("Meeting Room 1",ResolveNameSearchLocation.DirectoryOnly, true);
System.out.println("nameResolutions==="+nameResolutions.getCount());

for(NameResolution nameResolution : nameResolutions)
{
  	System.out.println("NAME==="+nameResolution.getContact().getName());


}

You should then be able to get what you want from the Contact object

Cheers
Glen

  • Marked as answer by Erkki.Solala Friday, August 03, 2012 8:11 AM
Free Windows Admin Tool Kit Click here and download it now
August 3rd, 2012 9:41am

You need to use the ResolveName operation and specify to return the Contact information from Active Directory in the Java EWS api you should be able to use the resolveName Method from the ExchangeService class eg something like

NameResolutionCollection nameResolutions = service.resolveName("Meeting Room 1",ResolveNameSearchLocation.DirectoryOnly, true);
System.out.println("nameResolutions==="+nameResolutions.getCount());

for(NameResolution nameResolution : nameResolutions)
{
  	System.out.println("NAME==="+nameResolution.getContact().getName());


}

You should then be able to get what you want from the Contact object

Cheers
Glen

  • Marked as answer by Erkki.Solala Friday, August 03, 2012 8:11 AM
August 3rd, 2012 9:41am

You need to use the ResolveName operation and specify to return the Contact information from Active Directory in the Java EWS api you should be able to use the resolveName Method from the ExchangeService class eg something like

NameResolutionCollection nameResolutions = service.resolveName("Meeting Room 1",ResolveNameSearchLocation.DirectoryOnly, true);
System.out.println("nameResolutions==="+nameResolutions.getCount());

for(NameResolution nameResolution : nameResolutions)
{
  	System.out.println("NAME==="+nameResolution.getContact().getName());


}

You should then be able to get what you want from the Contact object

Cheers
Glen

  • Marked as answer by Erkki.Solala Friday, August 03, 2012 8:11 AM
Free Windows Admin Tool Kit Click here and download it now
August 3rd, 2012 9:41am

Many thanks for help.

I was able to get the necessary information from Contact.


August 3rd, 2012 11:11am

Hi Glen,

Thanks for giving this code...With this code, i am able to fetch the name of the meeting rooms available.But i want to know, how to get the appointment of the particular room like what time rooms are booked along with date. Can, you please help me in it. I am using ews-java api

Thanks,

Akshea

Free Windows Admin Tool Kit Click here and download it now
February 16th, 2015 6:47am

There are two ways you could do that just use FindItem to query the Calendar Folder involved see "Get all appointments between startDate and endDate in the specified folder, including recurring meeting occurrences" in https://github.com/OfficeDev/ews-java-api

The other method you could use if you have multiple mailboxes you want to do this on is use the FreeBusy time via GetUserAvailabilty see the "Availability Service" section in the above link

Cheers
Glen

February 16th, 2015 7:29pm

Hi Glen,

I am able to understand what u have said, but do not know how to implement it with meeting rooms....

If i am implementing "Get all appointments between startDate and endDate in the specified folder, including recurring meeting occurrences" in ews-java-api, as you have mentioned above, i am able to get only my appointments from the start date to end date , as i have given my email id and password, how to get my organization meeting room details, booked or not.

static ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		
		ExchangeCredentials credentials = new WebCredentials("xxx@yy.com", "zzzz");
		service.setCredentials(credentials);
		try {
			System.out.println("Check");
			service.autodiscoverUrl("xxx@yy.com",new RedirectionUrlCallback());
			
			

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		NameResolutionCollection nameResolutions = service.resolveName("SDB1",ResolveNameSearchLocation.DirectoryOnly, true);
		System.out.println("nameResolutions==="+nameResolutions.getCount());

		for(NameResolution nameResolution : nameResolutions)
		{
		  	System.out.println("NAME==="+nameResolution.getContact().getDisplayName());


		}
	}

The above code gives me the output like, the meeting room in my organization with word SDB1 are

Output:

nameResolutions===2

NAME===SDB1- TELCON - 1

NAME===SDB1-TELCON - 2

 for. eg. I need to know today at what are the appointments in the room SDB1-TELCON2 and who all have booked the room.

I do not know how to implement for the meeting room can you please help me how to give it.

Thanks in advance.


  • Edited by Akshea 6 hours 24 minutes ago
Free Windows Admin Tool Kit Click here and download it now
February 17th, 2015 12:25am

Hi Glen,

I am able to understand what u have said, but do not know how to implement it with meeting rooms....

If i am implementing "Get all appointments between startDate and endDate in the specified folder, including recurring meeting occurrences" in ews-java-api, as you have mentioned above, i am able to get only my appointments from the start date to end date , as i have given my email id and password, how to get my organization meeting room details, booked or not.

static ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		
		ExchangeCredentials credentials = new WebCredentials("xxx@yy.com", "zzzz");
		service.setCredentials(credentials);
		try {
			System.out.println("Check");
			service.autodiscoverUrl("xxx@yy.com",new RedirectionUrlCallback());
			
			

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		NameResolutionCollection nameResolutions = service.resolveName("SDB1",ResolveNameSearchLocation.DirectoryOnly, true);
		System.out.println("nameResolutions==="+nameResolutions.getCount());

		for(NameResolution nameResolution : nameResolutions)
		{
		  	System.out.println("NAME==="+nameResolution.getContact().getDisplayName());


		}
	}

The above code gives me the output like, the meeting room in my organization with word SDB1 are

Output:

nameResolutions===2

NAME===SDB1- TELCON - 1

NAME===SDB1-TELCON - 2

 for. eg. I need to know today at what are the appointments in the room SDB1-TELCON2 and who all have booked the room.

I do not know how to implement for the meeting room can you please help me how to give it.

Thanks in advance.


  • Edited by Akshea Tuesday, February 17, 2015 5:24 AM
February 17th, 2015 8:20am

Hi Glen,

I am able to understand what u have said, but do not know how to implement it with meeting rooms....

If i am implementing "Get all appointments between startDate and endDate in the specified folder, including recurring meeting occurrences" in ews-java-api, as you have mentioned above, i am able to get only my appointments from the start date to end date , as i have given my email id and password, how to get my organization meeting room details, booked or not.

static ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		
		ExchangeCredentials credentials = new WebCredentials("xxx@yy.com", "zzzz");
		service.setCredentials(credentials);
		try {
			System.out.println("Check");
			service.autodiscoverUrl("xxx@yy.com",new RedirectionUrlCallback());
			
			

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		NameResolutionCollection nameResolutions = service.resolveName("SDB1",ResolveNameSearchLocation.DirectoryOnly, true);
		System.out.println("nameResolutions==="+nameResolutions.getCount());

		for(NameResolution nameResolution : nameResolutions)
		{
		  	System.out.println("NAME==="+nameResolution.getContact().getDisplayName());


		}
	}

The above code gives me the output like, the meeting room in my organization with word SDB1 are

Output:

nameResolutions===2

NAME===SDB1- TELCON - 1

NAME===SDB1-TELCON - 2

 for. eg. I need to know today at what are the appointments in the room SDB1-TELCON2 and who all have booked the room.

I do not know how to implement for the meeting room can you please help me how to give it.

Thanks in advance.


  • Edited by Akshea Tuesday, February 17, 2015 5:24 AM
Free Windows Admin Tool Kit Click here and download it now
February 17th, 2015 8:20am

Hi Glen,

I am able to understand what u have said, but do not know how to implement it with meeting rooms....

If i am implementing "Get all appointments between startDate and endDate in the specified folder, including recurring meeting occurrences" in ews-java-api, as you have mentioned above, i am able to get only my appointments from the start date to end date , as i have given my email id and password, how to get my organization meeting room details, booked or not.

static ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		
		ExchangeCredentials credentials = new WebCredentials("xxx@yy.com", "zzzz");
		service.setCredentials(credentials);
		try {
			System.out.println("Check");
			service.autodiscoverUrl("xxx@yy.com",new RedirectionUrlCallback());
			
			

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		NameResolutionCollection nameResolutions = service.resolveName("SDB1",ResolveNameSearchLocation.DirectoryOnly, true);
		System.out.println("nameResolutions==="+nameResolutions.getCount());

		for(NameResolution nameResolution : nameResolutions)
		{
		  	System.out.println("NAME==="+nameResolution.getContact().getDisplayName());


		}
	}

The above code gives me the output like, the meeting room in my organization with word SDB1 are

Output:

nameResolutions===2

NAME===SDB1- TELCON - 1

NAME===SDB1-TELCON - 2

 for. eg. I need to know today at what are the appointments in the room SDB1-TELCON2 and who all have booked the room.

I do not know how to implement for the meeting room can you please help me how to give it.

Thanks in advance.


  • Edited by Akshea Tuesday, February 17, 2015 5:24 AM
February 17th, 2015 8:20am

>i am able to get only my appointments from the start date to end date , as i have given my email id and password, how to get my organization meeting room details, booked or not.

You use exactly the same code but all you need to do is use FolderId class overload to specify Mailbox you want to access eg

            FolderId Calendar = new FolderId(WellKnownFolderName.Calendar, "Mailbox@domain");
            service.FindAppointments(Calendar,.....
Cheers
Glen

Free Windows Admin Tool Kit Click here and download it now
February 17th, 2015 10:27pm

Hi Glen,

Thanks, for your response....

What is that Mailbox@domain ? Is it the meeting room email id?

February 17th, 2015 11:26pm

Yes it needs to be the primarySMTP address of the Mailbox you want to access
Free Windows Admin Tool Kit Click here and download it now
February 17th, 2015 11:42pm

How could i get that primarySMTP address?
February 18th, 2015 12:07am

Suggest me some sample of it
Free Windows Admin Tool Kit Click here and download it now
February 18th, 2015 12:08am

Is it like my meeting room email id? SDB1-TELCON2@yy.com?

February 18th, 2015 12:23am

Hi Glen,

Along with the previous code mentioned, i have added the below code to get meeting room appointment, but it throws the following exception.

Exception in thread "main" microsoft.exchange.webservices.data.ServiceResponseException: The specified folder could not be found in the store.
	at microsoft.exchange.webservices.data.ServiceResponse.internalThrowIfNecessary(ServiceResponse.java:262)
	at microsoft.exchange.webservices.data.ServiceResponse.throwIfNecessary(ServiceResponse.java:251)
	at microsoft.exchange.webservices.data.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:146)
	at microsoft.exchange.webservices.data.ExchangeService.findItems(ExchangeService.java:807)
	at microsoft.exchange.webservices.data.ExchangeService.findAppointments(ExchangeService.java:1089)
	at com.hcl.GetRoomClass.main(GetRoomClass.java:58)

Here is my code:

Date startDate = new Date();
		
		Calendar cal = Calendar.getInstance();
		cal.setTime(startDate);
		cal.add(Calendar.DATE, 30); // add 10 days
		 
		Date endDate = cal.getTime();
		   Mailbox meetingMailbox = new Mailbox("SDB1-TELCON2@yy.com");
           FolderId CalendarId = new FolderId(WellKnownFolderName.Calendar, meetingMailbox);
           CalendarView cView = new CalendarView(startDate, endDate);
           FindItemsResults<Appointment> appointments = service.findAppointments(CalendarId, cView);
           for (Appointment a : appointments)
           {
               System.out.println("Subject: " + a.getSubject().toString() + " ");
               System.out.println("Start: " + a.getStart().toString() + " ");
               System.out.println("End: " + a.getEnd().toString());
               System.out.println();
           }

What is the problem? Am i not able to access the meeting room calendar.

Free Windows Admin Tool Kit Click here and download it now
February 18th, 2015 1:35am

HI glen, 

Can you please help in below exception caused

February 20th, 2015 9:43am

That error mean you don't have rights to the Mailbox Folder in question you need to grant the rights via either Add-MailboxPermission or Add-MailboxFolderPermission or use EWS Impersonation (Note you need to be able to open the Calendar folder in outlook using whatever user you running the code as, Admin rights mean nothing).

Cheers

Glen

Free Windows Admin Tool Kit Click here and download it now
February 22nd, 2015 5:36pm

Hi Glen,

Can i get any sample how to grant the rights via Add-Mailbox Permission using ews java api.....I am not having admin rights to use Impersonation. Please help me.

Thanks in advance

February 23rd, 2015 2:26am

Hi Glen,

can you please help me in it.

Free Windows Admin Tool Kit Click here and download it now
February 25th, 2015 5:03am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics